package algorithm.sort.review2;

import java.util.Arrays;

public class Insert {
    public static void main(String[] args) {
        int[] arr = {3, 3, 4, 1, 3, 56, 242, 1};
        insertSort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void insertSort(int[] arr) {
        if (arr.length < 2)
            return;
        int temp;
        for (int i = 1; i < arr.length; i++) {
            int j = i;
            temp = arr[i];
            while (j > 0 && temp < arr[j - 1]) {
                arr[j] = arr[j - 1];
                j--;
            }
            arr[j] = temp;
        }
    }
}
